<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: RubyMotionQuery::Color
  
    &mdash; Documentation by YARD 0.8.7.3
  
</title>

  <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />

  <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  hasFrames = window.top.frames.main ? true : false;
  relpath = '../';
  framesUrl = "../frames.html#!" + escape(window.location.href);
</script>


  <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>


  </head>
  <body>
    <div id="header">
      <div id="menu">
  
    <a href="../_index.html">Index (C)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../RubyMotionQuery.html" title="RubyMotionQuery (module)">RubyMotionQuery</a></span></span>
     &raquo; 
    <span class="title">Color</span>
  

  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="../class_list.html">
      Class List
    </a>
  
    <a class="full_list_link" id="method_list_link"
        href="../method_list.html">
      Method List
    </a>
  
    <a class="full_list_link" id="file_list_link"
        href="../file_list.html">
      File List
    </a>
  
</div>
      <div class="clear"></div>
    </div>

    <iframe id="search_frame"></iframe>

    <div id="content"><h1>Class: RubyMotionQuery::Color
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">UIColor</span>
      
        <ul class="fullTree">
          <li><span class='object_link'><a href="../Object.html" title="Object (class)">Object</a></span></li>
          
            <li class="next">UIColor</li>
          
            <li class="next">RubyMotionQuery::Color</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">motion/ruby_motion_query/color.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <p class="tag_title">Examples:</p>
    
      
      <pre class="example code"><code><span class='comment'># Standard colors:
</span>
<span class='comment'># In a stylesheet, you can just use color. Anywhere else these would be
</span><span class='comment'># rmq.color.clear, etc
</span>
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span>      
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_white'>white</span>      
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_light_gray'>light_gray</span> 
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_gray'>gray</span>       
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_dark_gray'>dark_gray</span>  
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_black'>black</span>      

<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_red'>red</span>        
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_green'>green</span>      
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_blue'>blue</span>       
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_yellow'>yellow</span>     
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_orange'>orange</span>     
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_purple'>purple</span>     
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_brown'>brown</span>      
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_cyan'>cyan</span>       
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_magenta'>magenta</span>    

<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_table_view'>table_view</span> 
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_scroll_view'>scroll_view</span>
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_flipside'>flipside</span>   
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_under_page'>under_page</span> 
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_light_text'>light_text</span> 
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_dark_text'>dark_text</span>  </code></pre>
    
  </div>


</div>






  
    <h2>
      Class Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#add_named-class_method" title="add_named (class method)">+ (UIColor) <strong>add_named</strong>(key, hex_or_color) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Add your own standard color.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#from_hex-class_method" title="from_hex (class method)">+ (UIColor) <strong>from_hex</strong>(hex_color) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Creates a color from a hex triplet.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#from_hsva-class_method" title="from_hsva (class method)">+ (UIColor) <strong>from_hsva</strong>(h, s, v, a) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#from_rgba-class_method" title="from_rgba (class method)">+ (UIColor) <strong>from_rgba</strong>(r, g, b, a) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#random-class_method" title="random (class method)">+ (Object) <strong>random</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
    </ul>
  


  

  <div id="class_method_details" class="method_details_list">
    <h2>Class Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="add_named-class_method">
  
    + (<tt>UIColor</tt>) <strong>add_named</strong>(key, hex_or_color) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Add your own standard color</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <p class="tag_title">Examples:</p>
    
      
      <pre class="example code"><code><span class='id identifier rubyid_rmq'>rmq</span><span class='period'>.</span><span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_add_named'>add_named</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>#ffffff</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_my_label'>my_label</span><span class='period'>.</span><span class='id identifier rubyid_color'>color</span> <span class='op'>=</span> <span class='id identifier rubyid_rmq'>rmq</span><span class='period'>.</span><span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_foo'>foo</span> <span class='comment'># or just color.foo in a stylesheet</span></code></pre>
    
  </div>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>UIColor</tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


77
78
79
80
81
82
83
84
85
86
87</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'motion/ruby_motion_query/color.rb', line 77</span>

<span class='kw'>def</span> <span class='id identifier rubyid_add_named'>add_named</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_hex_or_color'>hex_or_color</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_color'>color</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_hex_or_color'>hex_or_color</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span>
    <span class='const'>Color</span><span class='period'>.</span><span class='id identifier rubyid_from_hex'>from_hex</span><span class='lparen'>(</span><span class='id identifier rubyid_hex_or_color'>hex_or_color</span><span class='rparen'>)</span>
  <span class='kw'>else</span>
    <span class='id identifier rubyid_hex_or_color'>hex_or_color</span>
  <span class='kw'>end</span>

  <span class='const'>Color</span><span class='period'>.</span><span class='id identifier rubyid_define_singleton_method'>define_singleton_method</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='kw'>do</span>
    <span class='id identifier rubyid_color'>color</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="from_hex-class_method">
  
    + (<tt>UIColor</tt>) <strong>from_hex</strong>(hex_color) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Creates a color from a hex triplet</p>

<p>Thanks bubblewrap for this method</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <p class="tag_title">Examples:</p>
    
      
      <pre class="example code"><code><span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_from_hex'>from_hex</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>#ffffff</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_from_hex'>from_hex</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ffffff</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>hex</span>
      
      
        <span class='type'></span>
      
      
      
        &mdash;
        <div class='inline'>
<p>with or without the #</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>UIColor</tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'motion/ruby_motion_query/color.rb', line 98</span>

<span class='kw'>def</span> <span class='id identifier rubyid_from_hex'>from_hex</span><span class='lparen'>(</span><span class='id identifier rubyid_hex_color'>hex_color</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_hex_color'>hex_color</span> <span class='op'>=</span> <span class='id identifier rubyid_hex_color'>hex_color</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>#</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>   
  <span class='kw'>case</span> <span class='id identifier rubyid_hex_color'>hex_color</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> 
    <span class='kw'>when</span> <span class='int'>3</span>
      <span class='id identifier rubyid_colors'>colors</span> <span class='op'>=</span> <span class='id identifier rubyid_hex_color'>hex_color</span><span class='period'>.</span><span class='id identifier rubyid_scan'>scan</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>%r{</span><span class='tstring_content'>[0-9A-Fa-f]</span><span class='regexp_end'>}</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_el'>el</span><span class='op'>|</span> <span class='lparen'>(</span><span class='id identifier rubyid_el'>el</span> <span class='op'>*</span> <span class='int'>2</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='lparen'>(</span><span class='int'>16</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
    <span class='kw'>when</span> <span class='int'>6</span>
      <span class='id identifier rubyid_colors'>colors</span> <span class='op'>=</span> <span class='id identifier rubyid_hex_color'>hex_color</span><span class='period'>.</span><span class='id identifier rubyid_scan'>scan</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>%r&lt;</span><span class='tstring_content'>[0-9A-Fa-f]{2}</span><span class='regexp_end'>&gt;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_el'>el</span><span class='op'>|</span> <span class='id identifier rubyid_el'>el</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='lparen'>(</span><span class='int'>16</span><span class='rparen'>)</span> <span class='rbrace'>}</span>        
    <span class='kw'>else</span>
      <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span>
  <span class='kw'>end</span> 
  <span class='kw'>if</span> <span class='id identifier rubyid_colors'>colors</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='int'>3</span>
    <span class='id identifier rubyid_from_rgba'>from_rgba</span><span class='lparen'>(</span><span class='id identifier rubyid_colors'>colors</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_colors'>colors</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_colors'>colors</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='float'>1.0</span><span class='rparen'>)</span>
  <span class='kw'>else</span>
    <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span>
  <span class='kw'>end</span> 
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="from_hsva-class_method">
  
    + (<tt>UIColor</tt>) <strong>from_hsva</strong>(h, s, v, a) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <p class="tag_title">Examples:</p>
    
      
      <pre class="example code"><code><span class='id identifier rubyid_rmq'>rmq</span><span class='period'>.</span><span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_from_hsva'>from_hsva</span><span class='lparen'>(</span><span class='int'>100</span><span class='comma'>,</span><span class='int'>140</span><span class='comma'>,</span><span class='int'>80</span><span class='comma'>,</span><span class='float'>1.0</span><span class='rparen'>)</span></code></pre>
    
  </div>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>UIColor</tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


127
128
129</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'motion/ruby_motion_query/color.rb', line 127</span>

<span class='kw'>def</span> <span class='id identifier rubyid_from_hsva'>from_hsva</span><span class='lparen'>(</span><span class='id identifier rubyid_h'>h</span><span class='comma'>,</span><span class='id identifier rubyid_s'>s</span><span class='comma'>,</span><span class='id identifier rubyid_v'>v</span><span class='comma'>,</span><span class='id identifier rubyid_a'>a</span><span class='rparen'>)</span>
  <span class='const'>UIColor</span><span class='period'>.</span><span class='id identifier rubyid_alloc'>alloc</span><span class='period'>.</span><span class='id identifier rubyid_initWithHue'>initWithHue</span><span class='lparen'>(</span><span class='id identifier rubyid_h'>h</span><span class='comma'>,</span> <span class='label'>saturation:</span> <span class='id identifier rubyid_s'>s</span><span class='comma'>,</span> <span class='label'>brightness:</span> <span class='id identifier rubyid_v'>v</span><span class='comma'>,</span> <span class='label'>alpha:</span> <span class='id identifier rubyid_a'>a</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="from_rgba-class_method">
  
    + (<tt>UIColor</tt>) <strong>from_rgba</strong>(r, g, b, a) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <p class="tag_title">Examples:</p>
    
      
      <pre class="example code"><code><span class='id identifier rubyid_rmq'>rmq</span><span class='period'>.</span><span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_from_rgba'>from_rgba</span><span class='lparen'>(</span><span class='int'>255</span><span class='comma'>,</span><span class='int'>255</span><span class='comma'>,</span><span class='int'>255</span><span class='comma'>,</span><span class='float'>0.5</span><span class='rparen'>)</span></code></pre>
    
  </div>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>UIColor</tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


119
120
121</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'motion/ruby_motion_query/color.rb', line 119</span>

<span class='kw'>def</span> <span class='id identifier rubyid_from_rgba'>from_rgba</span><span class='lparen'>(</span><span class='id identifier rubyid_r'>r</span><span class='comma'>,</span><span class='id identifier rubyid_g'>g</span><span class='comma'>,</span><span class='id identifier rubyid_b'>b</span><span class='comma'>,</span><span class='id identifier rubyid_a'>a</span><span class='rparen'>)</span>
  <span class='const'>UIColor</span><span class='period'>.</span><span class='id identifier rubyid_colorWithRed'>colorWithRed</span><span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_r'>r</span><span class='op'>/</span><span class='float'>255.0</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='label'>green:</span> <span class='lparen'>(</span><span class='id identifier rubyid_g'>g</span><span class='op'>/</span><span class='float'>255.0</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='label'>blue:</span> <span class='lparen'>(</span><span class='id identifier rubyid_b'>b</span><span class='op'>/</span><span class='float'>255.0</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='label'>alpha:</span> <span class='id identifier rubyid_a'>a</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="random-class_method">
  
    + (<tt><span class='object_link'><a href="../Object.html" title="Object (class)">Object</a></span></tt>) <strong>random</strong> 
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


131
132
133</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'motion/ruby_motion_query/color.rb', line 131</span>

<span class='kw'>def</span> <span class='id identifier rubyid_random'>random</span>
  <span class='id identifier rubyid_from_rgba'>from_rgba</span><span class='lparen'>(</span><span class='id identifier rubyid_rand'>rand</span><span class='lparen'>(</span><span class='int'>255</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_rand'>rand</span><span class='lparen'>(</span><span class='int'>255</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_rand'>rand</span><span class='lparen'>(</span><span class='int'>255</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='float'>1.0</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

    <div id="footer">
  Generated on Sun Dec  8 20:15:51 2013 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.8.7.3 (ruby-1.9.3).
</div>

  </body>
</html>